<template>
  <div class="preview">
    <el-dialog title="营销车票预览" width="1500px" :visible="true" :gutter="24" @close="close">
      <basic-container>
        <avue-crud
          ref="crud"
          :option="optionOne"
          :table-loading="listLoading"
          :data="listOne"
          @on-load="getSwStMarketingTicketOffineSell">
          <template slot="menuLeft">
            线下正常售卖(售票员)
          </template>
        </avue-crud>
        <avue-crud
          ref="crud"
          :option="optionTwo"
          :table-loading="listLoading"
          :data="listTwo"
          @on-load="getSwStMarketingTicketOffineTakeTicket">
          <template slot="receiptFilePath" slot-scope="scope">
            <el-button
              class="filter-item"
              type="primary"
              size="mini" @click="download(scope.row,1)">下载</el-button>
          </template>
          <template slot="menuLeft">
            转账/线下核销明细
          </template>
        </avue-crud>
        <avue-crud
          ref="crud"
          :option="optionThree"
          :table-loading="listLoading"
          :data="listThree"
          @on-load="getSwStMarketingTicketGroupSell">
          <template slot="receiptFilePath" slot-scope="scope">
            <el-button
              class="filter-item"
              type="primary"
              size="mini" @click="download(scope.row,2)">下载</el-button>
          </template>
          <template slot="menuLeft">
            团购售卖
          </template>
        </avue-crud>
      </basic-container>
      <div  style="text-align: center">
        <el-button type="primary" @click="close">返回</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import {mapGetters} from 'vuex';
  import { handleDown } from '@/util/util';
  import ElInput from "../../../../../node_modules/element-ui/packages/input/src/input";
  import transitUtil from "../../../../api/subwayRat/transitUtil";
  import {tableOptionOne,tableOptionTwo,tableOptionThree,getSwStMarketingTicketGroupSell,getSwStMarketingTicketOffineSell,getSwStMarketingTicketOffineTakeTicket
  } from '../../../../api/subwayRat/conductorDifferences/swAuConductorShort/preview';
  import {handleDownloadZip} from '@/util/util.js';
  export default {
    components: {ElInput},
    name: 'preview',
    data() {
      return {
        selectKeys:[], //存放对像
        selectKeyVals:[], //存放值
        optionOne: tableOptionOne,
        optionTwo: tableOptionTwo,
        optionThree: tableOptionThree,
        listLoading: true,
        page: {
          total: 0, // 总页数
          currentPage: 1, // 当前页数
          pageSize: 20, // 每页显示多少条,
          isAsc: false// 是否倒序
        },
        listOne : [],
        listTwo : [],
        listThree : []
      }
    },
    computed: {
    },
    watch: {
    },
    created() {
    },
    methods: {
      // download(row){
      //   handleDown(row.file,"zdkj")
      // },
      //回执单附件下载
      download(row,type) {
        let pathList = [];
        if(1==type){
          if (!this.validatenull(row.receiptFilePath)) {
            pathList.push(row.receiptFilePath);
          }
          if (pathList[0] == "[]" || pathList[0] == undefined || pathList[0] == null) {
            this.$message.info("无附件");
            return;
          }
          handleDownloadZip(pathList, "转账明细<"+row.ticketName+">回执单附件.zip");
        }else{
          if (!this.validatenull(row.receiptFilePath)) {
            pathList.push(row.receiptFilePath);
          }
          if (pathList[0] == "[]" || pathList[0] == undefined || pathList[0] == null) {
            this.$message.info("无附件");
            return;
          }
          handleDownloadZip(pathList, "团购售卖<"+row.ticketName+">回执单附件.zip");
        }

      },
      close(){
        this.$parent.isPreview=false;
      },
      getSwStMarketingTicketOffineSell() {
        this.listLoading = true;
        let id = this.$parent.rowData.id;
        getSwStMarketingTicketOffineSell({relationId:id}).then((response)=>{
          this.listOne = response.data.data
          this.listLoading = false
        });
      },
      getSwStMarketingTicketOffineTakeTicket() {
        this.listLoading = true;
        let id = this.$parent.rowData.id;
        getSwStMarketingTicketOffineTakeTicket({relationId:id}).then((response)=>{
          this.listTwo = response.data.data
          this.listLoading = false
        });
      },
      getSwStMarketingTicketGroupSell() {
        this.listLoading = true;
        let id = this.$parent.rowData.id;
        getSwStMarketingTicketGroupSell({relationId:id}).then((response)=>{
          this.listThree = response.data.data
          this.listLoading = false
        });
      }
    }
  }
</script>
<style lang="scss">
</style>
